import os
import django
import pandas as pd
from django.core.cache import cache
# from PeopleInfo.models import EntranceGuardList


# django.setup()
os.environ['DJANGO_SETTINGS_MODULE'] = 'DataManagement.settings.dev'
data = pd.read_excel('准入.xls')

access, no_access, no_people, no_cache, no_cache_and_no_mysql = 0, 0, 0, 0, 0
for item in data['xue_hao_']:

    key = 'access_check_{}'.format(item)
    res = cache.get(key)
    if not res:
        print('username: {}, redis: {}'.format(item, res))
        no_cache += 1
    elif res['code'] == 600200:
        access += 1
    elif res['code'] == 600607:
        no_people += 1
    else:
        print('username: {}, redis: {}'.format(item, res))
        no_access += 1

print('access: {}, no_access: {}, no_people: {}, no_cache: {}, no_cache_and_no_mysql: {}'.format(access, no_access, no_people, no_cache, no_cache_and_no_mysql))
